import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '编码',
    align: "center",
    sorter: true,
    dataIndex: 'code',
    width: 100
  },
  {
    title: '名称',
    align: "center",
    sorter: true,
    dataIndex: 'name',
    width: 150
  },
  {
    title: '税率',
    align: "center",
    sorter: true,
    dataIndex: 'taxRate',
    width: 80
  },
  // {
  //   title: '是否默认',
  //   align: "center",
  //   dataIndex: 'isDefault',
  //   customRender: ({ text }) => {
  //     return text==1?'是':'否'
  //   },
  // },
  {
    title: '是否增值税',
    align: "center",
    dataIndex: 'valueAddedTax',
    customRender: ({ text }) => {
      return text==1?'是':'否'
    },
    width: 120
  },
  {
    title: '税计算方法',
    align: "center",
    dataIndex: 'taxCalculationMethod',
    customRender: ({ text }) => {
      return text==0?'按金额扣税（外加）': text==1?'按金额扣税（内含）': text==2?'按其它税别税额扣税':''
    },
    width: 160
  },
  {
    title: '税别',
    align: "center",
    dataIndex: 'taxCategory',
    customRender: ({ text }) => {
      return text==0?'退补': text==1?'退扣': ''
    },
    width: 80
  },
  {
    title: '交货方式',
    align: "center",
    dataIndex: 'deliveryMethod',
    customRender: ({ text }) => {
      return text==0?'单据行税': text==1?'整单税': ''
    },
    width: 100
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
  {
    title: '第三方编码',
    align: "center",
    dataIndex: 'thirdPartyCode'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "编码",
    field: 'code',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "名称",
    field: 'name',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "税率",
    field: 'taxRate',
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编码',
    field: 'code',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入编码!' },
      ];
    },

  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入名称!' },
      ];
    },
  },
  {
    label: '税率',
    field: 'taxRate',
    component: 'InputNumber',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入税率!' },
      ];
    },
  },
  // {
  //   label: '是否默认',
  //   field: 'isDefault',
  //   defaultValue: 0,
  //   component: 'JSwitch',
  //   componentProps: {
  //     options: [1, 0]
  //   },
  // },
  {
    label: '增值税',
    field: 'valueAddedTax',
    defaultValue: 0,
    component: 'JSwitch',
    componentProps: {
      options: [1, 0]
    },
  },
  {
    label: '税计算方法',
    field: 'taxCalculationMethod',
    component: 'Select',
    defaultValue: 0,
    componentProps: {
      options: [{ label: '按金额扣税（外加）', value: 0 }, { label: '按金额扣税（内含）', value: 1 }, { label: '按其它税别税额扣税', value: 2 }]
    },
  },
  {
    label: '税别',
    field: 'taxCategory',
    component: 'Select',
    defaultValue: 0,
    componentProps: {
      options: [{ label: '退补', value: 0 }, { label: '退扣', value: 1 }]
    },
  },
  {
    label: '交货方式',
    field: 'deliveryMethod',
    component: 'Select',
    defaultValue: 0,
    componentProps: {
      options: [{ label: '单据行税', value: 0 }, { label: '整单税', value: 1 }]
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}